import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;


public class ButtonFrame extends JFrame {
	
	private JButton iconButton;
	private JButton textButton;
	
	public ButtonFrame() {
		super("ButtonFrame");
		setLayout(new FlowLayout());
		
		textButton = new JButton("Zwykly tekst");
		add(textButton);
		
		Icon bug1 = new ImageIcon(getClass().getResource("bug1.gif"));
		Icon bug2 = new ImageIcon(getClass().getResource("bug2.gif"));
		iconButton = new JButton("iconButton", bug1);
		iconButton.setRolloverIcon(bug2);
		add(iconButton);
		
		ButtonHandler handler = new ButtonHandler();
		textButton.addActionListener(handler);
		iconButton.addActionListener(handler);
	}
	
	private class ButtonHandler implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			JOptionPane.showMessageDialog(ButtonFrame.this, String.format("You have clicked %s", e.getActionCommand()));
			
		}
		
	}

}
